Crate flo_canvas[−][src]
flo_canvas
provides an abstraction of a 2D vector canvas, and supporting methods to stream
updates to implementations.
The main features that this library supports are the set of primitives in the Draw
enum, the
Canvas
type for streaming drawing instructions elsewhere, and the encoding and decoding
functions that can be used to send canvas instructions over a byte stream. Encoding uses MIME64
characters, so it's easy to embed encoded canvases in other protocols.
By itself, flo_canvas
is an excellent way to describe how a 2D scene should be rendered without
needing to depend on a system-specific library.
FlowBetween comes with several implementations of the canvas for generating the final rendered
results. Most notably, flo_render_canvas
will convert between a stream of Draw
instructions
and a stream of instructions suitable for rendering with most graphics APIs. The accompanying
flo_render
can render these instructions to OpenGL or Metal and flo_render_gl_offscreen
is
available to generate bitmap images on a variety of systems.
canvas.js
provides a Javascript implementation that can render the instructions to a HTML
canvas, and there are also Quartz and Cairo implementations of the canvas provided in FlowBetween's
user interface layers.
Structs
Canvas | A canvas is an abstract interface for drawing graphics. It doesn't actually provide a means to render anything, but rather a way to describe how things should be drawn and pass those on to a renderer elsewhere. |
CanvasDecoder | Represents a (stateful) canvas decoder |
CanvasGraphicsContext | Graphics context for a Canvas |
SpriteId | Identifier of a canvas 'sprite' |
Transform2D | Represents a 2D affine transformation matrix |
Enums
BlendMode | Blend mode to use when drawing |
Color | Representation of a colour |
ColorFormat | Possible formats of a colour value |
DecoderError | Possible error from the decoder |
Draw | Instructions for drawing to a canvas |
LineCap | How to cap lines |
LineJoin | Possible way to join lines |
SpriteTransform | Transformation to apply to a canvas 'sprite' |
StreamDecoderError | Error from either a decoder or the stream that's feeding it |
WindingRule | How a path should determine if it's an outer edge or not |
Traits
CanvasEncoding | Trait implemented by objects that can be encoded into a canvas |
GraphicsContext | A graphics context provides the basic set of graphics actions that can be performed |
GraphicsPrimitives | GraphicsPrimitives adds new primitives that can be built directly from a graphics context |
Functions
decode_drawing | Decodes a canvas drawing represented as an iterator of characters. If there's an error in the stream, it will be the last item decoded. |
decode_drawing_stream | Decodes a canvas drawing represented as a stream of characters. |
draw_circle | Returns the drawing commands for a circle |
draw_rect | Returns the drawing commands for a rectangle |
gc_draw_bezier | Draws the specified bezier curve in a graphics context (assuming we're already at the start position) |